package com.dragon.repository.domain.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Vendor;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class VendorDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "供应商名称")
    private String name;

    @ApiModelProperty(value = "供应商电话")
    private String telephone;

    @ApiModelProperty(value = "供应商地址")
    private String address;

    @ApiModelProperty(value = "删除标识0未删除1删除")
    private Integer deleted;

    @ApiModelProperty(value = "供应商分类：1原材料 2零部件 3成品")
    private Integer vendorCategory;

    @ApiModelProperty(value = "信用评级")
    private Integer creditRating;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @ApiModelProperty(value = "修改时间")
    private Date updateTime;

    @ApiModelProperty(value = "供应商产品")
    private String vendorProduct;
    //private Product product;
    //private List<Product> productList;

    @ApiModelProperty(value = "供应商分类名称")
    private String vendorCategoryName;


    public VendorDTO() {}

    public VendorDTO(Vendor entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static VendorDTO convert(Vendor entity) {
        return new VendorDTO(entity);
    }

    public static List<VendorDTO> convertList(List<Vendor> list) {
        List<VendorDTO> resultList = new ArrayList<>();
        for (Vendor entity : list) {
            resultList.add(new VendorDTO(entity));
        }
        return resultList;
    }}
